<template>
  <!-- 输入框 -->
  <div class="el_input_box showInput WithdrawalRinput">
    <div
      class="el-input el-input-group input_box_style el-input-group--prepend"
    >
      <div class="el-input-group__prepend">
        <p class="head"></p>
        <div class="country">
          <NuxtImg src="/images/layout/footer_1.png" />
          <span>
            {{ lang.brl }}
          </span>
        </div>
      </div>
      <div class="el-input__wrapper" tabindex="-1">
        <input
          class="el-input__inner"
          type="Number"
          autocomplete="off"
          tabindex="0"
          :placeholder="`${lang.brl_placeholder} ≥ ${placeholderNum}${lang.brl}`"
        />
      </div>
    </div>
  </div>
  <!-- 文案 -->
  <div class="txt_box">
    <div>
      <div>
        <span>{{ lang.taxa }}: </span
        ><span class="tb-2">{{ formData.percent }}%</span>
      </div>
      <div>
        <span>{{ lang.valor_a_receber }}: </span>
        <span class="tb-2">{{ userStore.moneyUnit }} {{ formData.total }}</span>
      </div>
      <NuxtImg
        :class="{ open_arrow: isOpen }"
        src="/images/layout/down_arrow.png"
        @click="isOpen = !isOpen"
      />
    </div>
    <div class="list" :class="{ hidden_list: !isOpen }">
      <div>
        <span>{{ lang.limite_de_saque_diaria }}: </span
        ><span>{{ formData.limit }}</span>
      </div>
      <div>
        <span>{{ lang.vezes_de_saque_diaria }}: </span
        ><span>{{ formData.vezes }}</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
const lang: any = getCurrentPageLang("carteira");

const userStore = useUserStore();

const formData = ref({
  percent: 0,
  total: "0,00",
  limit: 50000,
  vezes: 10,
});

const isOpen = ref(true);

const placeholderNum = ref(20);

// 初始化状态
function initData() {
  isOpen.value = true;
}
onMounted(() => {
  initData();
});
watch(
  () => userStore.showCarteira,
  (val) => {
    if (!val) return;
    initData();
  }
);
</script>

<style scoped lang="scss">
.txt_box {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  margin-top: 0.3rem;
  margin-bottom: 0.3rem;
}
.txt_box > div {
  display: flex;
  width: 100%;
  margin-bottom: 0.12rem;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.38rem;
  color: #d390ff;
}
.txt_box .tb-2 {
  color: #ffb867;
}
.txt_box > div span {
  font-size: 0.32rem;
}
.txt_box img {
  width: 0.6rem;
  height: 0.6rem;
  transition: transform 0.2s ease;
}
.open_arrow {
  transform: rotate(-180deg);
}
.list {
  transition: transform 0.2s ease, opacity 0.2s ease;
  transform: scaleY(1);
  transform-origin: top;
  opacity: 1;
  overflow: hidden;
  will-change: transform, opacity;
  flex-wrap: wrap;
  > div {
    display: flex;
    width: 100%;
    margin-bottom: 0.12rem;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    color: #86718c;
    span {
      font-size: 0.3rem !important;
    }
  }
}
.hidden_list {
  transform: scaleY(0);
  opacity: 0;
  height: 0; /* 收起时布局高度为0 */
  pointer-events: none; /* 避免交互 */
}
.el_input_box {
  position: relative !important;
  border-radius: 0.2rem;
  border: 0.03rem solid var(--border-color);
}
.el_input_box .input_box_style {
  position: relative;
  display: grid;
  grid-template-columns: 13% 1fr;
  border-radius: 0.2rem;
}
.input_box_style {
  background-color: #312734;
}
.WithdrawalRinput .el-input-group__prepend {
  width: 1.6rem;
}
.el-input-group__prepend {
  width: 0.5rem;
  background: none;
  box-shadow: none;
  box-sizing: border-box;
  position: relative;
  font-size: 0.38rem;
  height: 100%;
  padding: 0;
}
.el-input-group__prepend {
  border-bottom-right-radius: 0;
  border-right: 0;
  border-top-right-radius: 0;
  box-shadow: 1px 0 0 0 var(--el-input-border-color) inset,
    0 1px 0 0 var(--el-input-border-color) inset,
    0 -1px 0 0 var(--el-input-border-color) inset;
}
.el-input-group__append,
.el-input-group__prepend {
  align-items: center;
  background-color: var(--el-fill-color-light);
  border-radius: var(--el-input-border-radius);
  color: var(--el-color-info);
  display: inline-flex;
  justify-content: center;
  min-height: 100%;
  padding: 0 20px;
  position: relative;
  white-space: nowrap;
}
.el-input-group__prepend:before {
  content: "";
  position: absolute;
  right: -0.5rem;
  width: 0.03rem;
  height: 0.6rem;
  background: var(--border-color);
  border-radius: 0.2rem;
}
.head {
  text-align: left;
}
.el-input {
  padding: 0 0.3rem;
  height: 1.1rem;
}
.country {
  width: 3rem;
  display: flex;
  justify-content: center;
  align-items: center;
}
.country img {
  width: 0.8rem;
  height: 0.8rem;
  margin-right: 0.36rem;
}
.WithdrawalRinput .country img {
  margin-right: 0.2rem;
}
.country span {
  font-size: 0.38rem;
  color: var(--theme-neutral1);
}
.el-input__wrapper {
  align-items: center;
  background-color: var(--el-input-bg-color, var(--el-fill-color-blank));
  background-image: none;
  border-radius: var(--el-input-border-radius, var(--el-border-radius-base));
  box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color))
    inset;
  cursor: text;
  display: inline-flex;
  flex-grow: 1;
  justify-content: center;
  padding: 1px 11px;
  transform: translateZ(0);
  transition: var(--el-transition-box-shadow);
}
.input_box_style .el-input__wrapper {
  background: transparent;
  border-radius: 0.2rem;
}
.el-input-group--prepend > .el-input__wrapper,
.el-input-group__append {
  border-bottom-left-radius: 0;
  border-top-left-radius: 0;
}
.el-input__wrapper,
.el-input__wrapper input {
  background-color: transparent !important;
}
.el_input_box .input_box_style .el-input__wrapper {
  box-shadow: none;
  width: calc(100% - 1rem);
}
.WithdrawalRinput .el-input__wrapper {
  margin-left: 1rem;
}
.el-input__inner {
  --el-input-inner-height: calc(var(--el-input-height, 32px) - 2px);
  -webkit-appearance: none;
  background: none;
  border: none;
  box-sizing: border-box;
  color: var(--el-input-text-color, var(--el-text-color-regular));
  flex-grow: 1;
  font-size: inherit;
  height: var(--el-input-inner-height);
  line-height: var(--el-input-inner-height);
  outline: none;
  padding: 0;
  width: 100%;
}
.el-input__inner[type="number"] {
  line-height: 1;
}
.input_box_style .el-input__wrapper .el-input__inner {
  --el-input-inner-height: 0.48rem;
  font-size: 0.35rem;
  color: var(--theme-neutral1);
}
.el_input_box .input_box_style .el-input__wrapper input {
  height: 100%;
  --el-input-inner-height: 0.3rem;
  color: var(--theme-neutral1);
}
</style>
